#include "musicsearch.h"


//从当前歌单查找歌曲
void MainWindow::handleSongSearch()
{
    bool shouldHide = false;
    QString search_text=ui->song_search->text();
    QStandardItemModel* model = qobject_cast<QStandardItemModel*>(ui->music_list->model());
    for (int i = 0; i < ui->music_list->model()->rowCount(); ++i) {
        QStandardItem *item =model->item(i,1);//一开始是0
        // 检查是否包含文本（不区分大小写）

        if(!item->text().contains(search_text, Qt::CaseInsensitive))
        {
            shouldHide=true;
            qDebug()<<item->text()<<search_text;
        }
        else
        {
            shouldHide = false;
        }
        ui->music_list->setRowHidden(i, shouldHide);
    }
}
